<template>
	<view>

		<view class="container">
			<!-- 我的信息 -->
			<view class="user-info-bg" :style="{ 'padding-top': topHeadHeight + 20 + 'rpx' }"></view>
			<view class="user-info" :style="{ 'padding-top': topHeadHeight + 20 + 'rpx' }">
				<view class="user-info-img-box">
					<view class="user-info-img-content">
						<image class="user-info-img" :src="userInfo.avatar" mode=""></image>
					</view>
				</view>
				<view class="">
					{{userInfo.nickname}}
				</view>
			</view>

			<!-- 功能列表 -->
			<view class="function-box">
				<view class="function-item" @click="navigateTo" data-url="/subPages/orderList/orderList?type=1">
					<view class="iconfont icon-dingdan function-item-left"></view>
					<view class="">
						订单列表
					</view>
				</view>

				<view class="function-item" @click="navigateTo" data-url="/subPages/agreement/agreement?id=-1">
					<view class="iconfont icon-gaizhang function-item-left"></view>
					<view class="">
						协议列表
					</view>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	// aa6dd3b0ff505c7255f092ed3aa04da6  小程序秘钥
	export default {
		data() {
			return {
				topHeadHeight: 172,
				userInfo: {}, //用户信息
			}
		},

		onLoad() {
			// 计算顶部导航栏高度
			this.topHeadHeight = uni.getStorageSync('headHeight') * 2 || 172;
		},

		onShow() {
			this.getuserinfo();
		},

		methods: {
			// 页面跳转
			navigateTo(e) {
				wx.navigateTo({
					url: e.currentTarget.dataset.url
				})
			},

			// 获取个人信息
			async getuserinfo() {
				let res = await this.$api.getuserinfo()
				this.userInfo = res.data
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		.user-info-bg {
			position: absolute;
			height: 400rpx;
			width: 100%;
			z-index: -1002;
			background: linear-gradient(#7e5a91 0%, #7e5a91 30%, RGBA(126, 90, 145, 0) 100%);
		}

		.user-info {
			text-align: center;
			font-size: 28rpx;
			height: 400rpx;
			color: white;

			.user-info-img-box {
				margin-bottom: 20rpx;
				border-radius: 50rpx;
				padding-top: 10rpx;
				display: flex;
				justify-content: space-around;

				.user-info-img-content {
					border-radius: 100rpx;
					background-color: white;
					width: 150rpx;
					height: 150rpx;

					.user-info-img {
						border-radius: 100rpx;
						width: 150rpx;
						height: 150rpx;
					}
				}


			}
		}

		.function-box {
			padding: 20rpx;
			font-size: 26rpx;

			.function-item {
				display: flex;
				border: 1rpx solid #ddd;
				height: 70rpx;
				line-height: 70rpx;
				border-radius: 10rpx;
				padding: 0 10rpx;
				box-shadow: 0rpx 3rpx 4rpx #bbb;
				margin-bottom: 30rpx;

				.function-item-left {
					margin-right: 10rpx;
					color: #7e5a91;
				}
			}
		}
	}
</style>